function [results,cells]=find_LFMcells_meta(proj_meta,cur_site,resp)

res_fpath='D:\RawData\zmarpawe';
if resp==1
    new_name=['LFMres_' num2str(cur_site) '.txt'];
elseif resp==2
    new_name=['FFMres_' num2str(cur_site) '.txt'];
elseif resp==3
    new_name=['LFMfbpbres_' num2str(cur_site) '.txt'];
elseif resp==4
    new_name=['LFMfbres_' num2str(cur_site) '.txt'];
elseif resp==5;
    new_name=['LFMfbpbFFMfbres_' num2str(cur_site) '.txt'];
end
cells=[];
cnt=1;
results={};
for tnd=1:length(proj_meta(cur_site).ExpGroup)
    for gnd=1:proj_meta(cur_site).nbr_piezo_layers
        for fnd=1:size(proj_meta(cur_site).raw_data(gnd,tnd).smoothed_ROIs,2)
            cur_act=proj_meta(cur_site).raw_data(gnd,tnd).smoothed_ROIs(fnd).activity/median(proj_meta(cur_site).raw_data(gnd,tnd).smoothed_ROIs(fnd).activity);
            if proj_meta(cur_site).ExpGroup(tnd)==5390
                frames=proj_meta(cur_site).raw_data(gnd,tnd).nbr_frames;
                frames(end)=frames(end)-125;
                [fb_snips_av,pb_snips_av,~,~]=pert_ana_meta(frames,...
                    proj_meta(cur_site).raw_data(gnd,tnd).stim_id,proj_meta(cur_site).raw_data(gnd,tnd).velM_ind,...
                    proj_meta(cur_site).raw_data(gnd,tnd).velP_ind,proj_meta(cur_site).raw_data(gnd,tnd).velM_raw,cur_act);
            else
                [fb_snips_av,pb_snips_av,~,~]=pert_ana_meta(proj_meta(cur_site).raw_data(gnd,tnd).nbr_frames,...
                    proj_meta(cur_site).raw_data(gnd,tnd).stim_id,proj_meta(cur_site).raw_data(gnd,tnd).velM_ind,...
                    proj_meta(cur_site).raw_data(gnd,tnd).velP_ind,proj_meta(cur_site).raw_data(gnd,tnd).velM_raw,cur_act);
            end
            outcome=0;
            if ~isempty(fb_snips_av{13})&~isempty(pb_snips_av{13})
                if resp==1
                    outcome=det_LFM_resp(fb_snips_av,pb_snips_av);
                elseif resp==2
                    outcome=det_FFM_resp(fb_snips_av,pb_snips_av);
                elseif resp==3
                    outcome=det_LFMfbpb_resp(fb_snips_av,pb_snips_av);
                elseif resp==4
                    outcome=det_LFMfb_resp(fb_snips_av,pb_snips_av);
                elseif resp==5
                    outcome=det_LFMfbpb_FFMfb_resp(fb_snips_av,pb_snips_av);
                end
            end
            if outcome==1
%                 display(['************************************************'])
%                 display(['time point: ' num2str(tnd) ' cell ' num2str(fnd) ' layer: ' num2str(gnd)])
%                 curYmax=0;
%                 for ond=1:length(fb_snips_av);
%                     if isempty(fb_snips_av{ond})
%                         snipy(ond)=0;
%                     else
%                         snipy(ond)=max([max(fb_snips_av{ond}) max(pb_snips_av{ond})]);
%                     end
%                 end
%                 curYmax=max([curYmax max(snipy) 1]);
%                 curYmax=curYmax+0.1;
%                 sequ=[1 2 3 8 9 10 4 5 6 11 12 13 7];
%                 figure;
%                 for cnd=1:length(fb_snips_av)
%                     subplot(2,7,sequ(cnd))
%                     if cnd==1
%                         title(['cell ' num2str(fnd) ' z: ' num2str(gnd)])
%                     end
%                     rectangle('position',[15 0 10 4],'facecolor',[0.95 0.95 0.95],'linestyle','none')
%                     if ~isempty(fb_snips_av{cnd})
%                         hold on
%                         plot(fb_snips_av{cnd},'color',[1 0 0],'LineWidth',2)
%                     end
%                     if ~isempty(pb_snips_av{cnd})
%                         hold on
%                         plot(pb_snips_av{cnd},'color',[0 0 0],'LineWidth',2)
%                     end
%                     axis tight
%                     %                     axis off
%                     box off
%                     ylim([0.8 curYmax])
%                     xlim([0 41])
%                     drawnow
%                 end
                ag = findobj; % all graphical objects
                nf = max(ag(find(ag==fix(ag)))); % maximal integer value is number of figures
                %                 display(['figure: ' num2str(nf)])
                %                 display(['************************************************'])
                results{cnt}=['time point: ' num2str(tnd) ' cell: ' num2str(fnd) ' layer: ' num2str(gnd) ' figure: ' num2str(nf)];
                cells(cnt,:)=[tnd fnd gnd nf];
                cnt=cnt+1;
            end
        end
    end
end
fid=fopen([res_fpath '\' new_name],'w');
fprintf(fid,'%s\r\n',results{1,:});
fclose(fid);